package com.longge;


import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;
import java.util.Objects;

public class SwapPairs {


    private static final LocalDate MONDAY = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
    private static final String[] WEEK = {"周一", "周二", "周三", "周四", "周五", "周六", "周日"};

    public ListNode swapPairs(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        ListNode newHead = head.next;
        head.next = swapPairs(newHead.next);
        newHead.next = head;
        return newHead;

    }

    public static void main(String[] args) {
        Date date = new Date(1648554184000L);
        if (Objects.isNull(date) || date.after(new Date())) {
            System.out.println("1111111");
        }
        SimpleDateFormat sd = new SimpleDateFormat("HH:mm");
        String dayDesc;
        String timeDesc = sd.format(date);
        LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
        if (localDate.isBefore(MONDAY)) {
            dayDesc = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        } else {
            int i = (int) MONDAY.until(localDate, ChronoUnit.DAYS);
            dayDesc = WEEK[i];
        }
        System.out.println(dayDesc);
        System.out.println(timeDesc);
    }


}
